<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="author" content="" />
<link href="../../css/main.css" rel="stylesheet" />
<link href="../../css/themes/default.css" rel="stylesheet" type="text/css"/>
<link href="../../css/themes/mac_os_x.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../js/prototype.js"></script>
<script type="text/javascript" src="../../js/scriptaculous.js"></script>
<script type="text/javascript" src="../../js/controls.js"></script>
<script type="text/javascript" src="../../js/page.js"></script>
<script type="text/javascript" src="../../js/window.js"></script>
<script type="text/javascript" src="../../js/window_effects.js"></script>
<script type="text/javascript">
var win;
function cdc(classe, musicale){
	if(musicale == 1)
		ht = 580;
	else
		ht = 467;
    //var pop = window.open_centered("cdc.php?offset=<?php print $offset ?>&id="+classe, "cdc", 450, ht, "");
    win = new Window({className: "mac_os_x", url: "cdc.php?offset=<?php print $offset ?>&id="+classe,  width:450, height: ht, zIndex: 100, resizable: true, title: "Consiglio di classe", showEffect:Effect.Appear, hideEffect: Effect.Fade, draggable:true, wiredDrag: true});
	win.showCenter(false);
	
}

</script>
</head>
<body>
    <div id="header">
		<div class="wrap">
			<?php include "../header.php" ?>
		</div>
	</div>
	<div class="wrap">
	<div id="main" style="background-color: #FFFFFF; padding-bottom: 30px; width: 100%">
        <form method="post">
        <table class="admin_table">
            <tr class="admin_title_row">
                <td colspan="4">Elenco classi: pagina <?php print $page ?> di <?php print $pagine ?></td>
            </tr>
            <tr>
                <td style="padding-left: 2px; width: 5%" class="adm_titolo_elenco">Classe</td>
                <td style="padding-left: 10px; width: 15%" class="adm_titolo_elenco">Sede</td>
                <td style="padding-left: 10px; width: 10%" class="adm_titolo_elenco">Alunni</td>
                <td style="width: 70%" class="adm_titolo_elenco">Consiglio di classe</td>
            </tr>
            <tr class="admin_row">
                <td id="row_before" colspan="4"></td>
            </tr>
            <?php
            $x = 1;
            if($res_cls->num_rows > $limit)
                $max = $limit;
            else
                $max = $res_cls->num_rows;

            while($class = $res_cls->fetch_assoc()){
                if($x > $limit) break;
                $cdc = "";
                // estrazione consiglio di classe
                $sel_state = "SELECT count(*) AS count FROM cdc WHERE id_anno = $anno AND id_classe = ".$class['id_classe']." AND id_docente IS NOT NULL AND id_materia <>11";
                //print $sel_state;
                $not_nulls = $db->executeCount($sel_state);
                
                $sel_cdc = "SELECT nome, cognome FROM utenti, docenti, cdc WHERE uid = docenti.id_docente AND docenti.id_docente = cdc.id_docente AND cdc.id_anno = $anno AND cdc.id_classe = ".$class['id_classe'];
                $res_cdc = $db->executeQuery($sel_cdc);
                $num_docenti = $res_cdc->num_rows;
                //print $sel_cdc;
                if($num_docenti > 0){ 
                    while($doc = $res_cdc->fetch_assoc())
                        $cdc .= $doc['cognome']." ".$doc['nome'].", ";
                    $cdc = substr($cdc, 0, (strlen($cdc) - 2));
                }
                
                $sel_students_count = "SELECT COUNT(*) FROM alunni WHERE id_classe = ".$class['id_classe'];
                $stud_count = $db->executeCount($sel_students_count);
            ?>
            <tr class="admin_row<?php if($x % 2) print(" odd") ?>">
                <td><a href="orario.php?cls=<?php print $class['id_classe'] ?>&tp=<?php print $class['tempo_prolungato'] ?>&desc=<?php print $class['anno_corso']."".$class['sezione'] ?>"><?php print $class['anno_corso']." ".$class['sezione'] ?></a></td>
                <td><?php print $class['nome'] ?></td>
                <td style="color: #003366; text-align: center"><a href="alunni.php?id_classe=<?php print $class['id_classe'] ?>"><?php print $stud_count ?></a></td>
                <td><a href="#" onclick="cdc(<?php print $class['id_classe'] ?>, <?php if($class['sezione'] == "C") print "1"; else print "0" ?>)"><?php if($cdc != "") print("$cdc"); else print "Inserisci" ?></a></td>
            </tr>
            <?php
                $x++;
            }
            include "../../shared/navigate.php";
            ?>
            <tr class="admin_row admin_menu">
                <td colspan="4">
                    <a href="../index.php">Torna Menu</a>
                </td>
            </tr>
            <tr class="admin_row">
                <td colspan="4">&nbsp;&nbsp;&nbsp;</td>
            </tr>
        </table>
        </form>
        </div>
        <div id="footer">
			<p>Design: Luka Cvrk - <a href="http://www.solucija.com" title="Free Web Templates">Solucija</a></p>
		</div>
	</div>
</body>
</html>